Skip to content

media: Add page alignment and lockless decommit - #11550

Merged
xiaomings merged 1 commit into
youtube:mainfrom
xiaomings:decoder_buffer
Jul 28, 2026
Merged

media: Add page alignment and lockless decommit#11550
xiaomings merged 1 commit into
youtube:mainfrom
xiaomings:decoder_buffer

Conversation

@xiaomings

@xiaomings xiaomings commented Jul 26, 2026

Copy link
Copy Markdown
Member

Add support for a page alignment flag in DecoderBufferAllocator to
control OS block allocation alignment. This allows for more granular
memory management when using the configurable decommit strategy.

Implement a lockless optimization during suspend by checking an atomic
flag before acquiring the allocator mutex. This prevents unnecessary
blocking of the UI thread when decommit on suspend is not enabled.

Additionally, simplify pointer arithmetic in StarboardMemoryAllocator
using uint8_t pointers and update H5vcc settings to expose the new
alignment configuration bit.

Bug: 454441375

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


media: Add page alignment and lockless decommit

Add support for a page alignment flag in DecoderBufferAllocator to
control OS block allocation alignment. This allows for more granular
memory management when using the configurable decommit strategy.

Implement a lockless optimization during suspend by checking an atomic
flag before acquiring the allocator mutex. This prevents unnecessary
blocking of the UI thread when decommit on suspend is not enabled.

Additionally, simplify pointer arithmetic in StarboardMemoryAllocator
using uint8_t pointers and update H5vcc settings to expose the new
alignment configuration bit.

Bug: 454441375

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@xiaomings xiaomings changed the title media: Add page alignment flag and lockless suspend decommit in DecoderBufferAllocator media: Add page alignment and lockless decommit Jul 26, 2026
@xiaomings

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a configurable page alignment option (allocate_with_page_alignment) to the DecoderBufferAllocator and StarboardMemoryAllocator strategies, and updates H5vccSettings to allow configuring this option via a bitmask. The review feedback highlights a backward compatibility issue where existing configurations would silently disable page alignment, suggesting to treat the new bit as a disable flag instead. Additionally, the reviewer recommends using uintptr_t instead of uint8_t* for alignment calculations in StarboardMemoryAllocator to prevent potential compilation issues, and updating the corresponding documentation comments.

Comment thread media/starboard/starboard_memory_allocator.h
…erBufferAllocator

Add support for the allocate_with_page_alignment flag to the configurable decommit strategy. This flag is bound to bit 25 (the second bit of the highest byte) of the setting and controls whether the fallback block allocator forces page alignment and page-rounded size. Additionally, implement a lockless suspend decommit optimization by checking the decommit_on_suspend_enabled_ atomic flag before acquiring the mutex. This prevents UI thread blocking on suspend when decommits are disabled. Also simplify StarboardMemoryAllocator pointer arithmetic inside Decommit() using uint8_t*, clean up redundant constructors, and standardize parameter documentation.

Bug: 454441375

TAG=agy

CONV=92545d5a-4b8a-4031-bbd7-3775e458e496
@xiaomings
xiaomings marked this pull request as ready for review July 27, 2026 21:59
@xiaomings
xiaomings requested review from a team as code owners July 27, 2026 21:59
@xiaomings
xiaomings enabled auto-merge (squash) July 27, 2026 21:59

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an allocate_with_page_alignment option to control page alignment for memory allocations in DecoderBufferAllocator and StarboardMemoryAllocator, alongside a lockless check for decommitting on suspend. The review feedback highlights a backward compatibility risk in parsing the configuration flags that could silently disable page alignment, potential compilation issues from using uint8_t* pointers with alignment functions, and potential test pollution from unconditionally storing true in the atomic decommit_on_suspend_enabled_ flag.

Comment thread media/starboard/starboard_memory_allocator.h
Comment thread media/starboard/decoder_buffer_allocator.cc

@hlwarriner hlwarriner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third_party/blink/renderer/modules/cobalt/h5vcc_settings/h_5_vcc_settings.cc changes LGTM, as long as web clients are aware of the encoding change for the setting.

@xiaomings
xiaomings merged commit 8ac74bd into youtube:main Jul 28, 2026
672 of 863 checks passed
@github-actions github-actions Bot added the cp-27.lts Cherry Pick to the 27.lts branch label Jul 28, 2026
cobalt-github-releaser-bot pushed a commit that referenced this pull request Jul 28, 2026
Refer to original PR: #11550

Add support for a page alignment flag in DecoderBufferAllocator to
control OS block allocation alignment. This allows for more granular
memory management when using the configurable decommit strategy.

Implement a lockless optimization during suspend by checking an atomic
flag before acquiring the allocator mutex. This prevents unnecessary
blocking of the UI thread when decommit on suspend is not enabled.

Additionally, simplify pointer arithmetic in StarboardMemoryAllocator
using uint8_t pointers and update H5vcc settings to expose the new
alignment configuration bit.

Bug: 454441375

(cherry picked from commit 8ac74bd)
briantting pushed a commit that referenced this pull request Jul 28, 2026
Refer to original PR: #11550

Add support for a page alignment flag in DecoderBufferAllocator to
control OS block allocation alignment. This allows for more granular
memory management when using the configurable decommit strategy.

Implement a lockless optimization during suspend by checking an atomic
flag before acquiring the allocator mutex. This prevents unnecessary
blocking of the UI thread when decommit on suspend is not enabled.

Additionally, simplify pointer arithmetic in StarboardMemoryAllocator
using uint8_t pointers and update H5vcc settings to expose the new
alignment configuration bit.

Bug: 454441375

(cherry picked from commit 8ac74bd)
@xiaomings
xiaomings deleted the decoder_buffer branch July 28, 2026 20:16
briantting pushed a commit that referenced this pull request Jul 28, 2026
Refer to original PR: #11550

Add support for a page alignment flag in DecoderBufferAllocator to
control OS block allocation alignment. This allows for more granular
memory management when using the configurable decommit strategy.

Implement a lockless optimization during suspend by checking an atomic
flag before acquiring the allocator mutex. This prevents unnecessary
blocking of the UI thread when decommit on suspend is not enabled.

Additionally, simplify pointer arithmetic in StarboardMemoryAllocator
using uint8_t pointers and update H5vcc settings to expose the new
alignment configuration bit.

Bug: 454441375

(cherry picked from commit 8ac74bd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp-27.lts Cherry Pick to the 27.lts branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants